home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / demo / mag / trash3_2.lha / fuentes / STARTUP-FUENTES.lha / Start500.s < prev    next >
Text File  |  1996-12-07  |  11KB  |  399 lines

  1. ;-----------------------------------------
  2. ;                                        
  3. ; Generic Demo Startup Code version 1.06
  4. ; Coded by Flynn/Capsule in 1996.        
  5. ;                                        
  6. ; * Works on ALL Amigas.                 
  7. ; * Special A500 version for Sapphire/Centolos            
  8. ; * Full 68000 - 68060 support.
  9. ;                                        
  10. ;-----------------------------------------
  11.  
  12.         INCLUDE Include:macros/macros.i
  13.  
  14.  
  15.     IFD    _PHXASS_    ;
  16.     MACHINE 68030        ; Comentar estas lineas para DevPac o
  17.     ENDIF            ; AsmOne, solo son para PHXAss
  18.  
  19.     section    startup,code
  20.     
  21. Start
  22.  
  23. ;-----------------
  24. ; Processor check.
  25. ;-----------------
  26.  
  27.         move.l  4.w,a6          ; exec base.
  28.         move.w  $128(a6),d0     ; AttnFlags
  29.  
  30.         lea     _cpu,a1
  31.         lea     _status,a2
  32.     lea    _warning,a3    ; Warning flag for 68000
  33.         
  34.         btst    #0,d0
  35.         bne.s   _010            ; 68010
  36.         move.b  #"0",(a1)
  37.         move.w  #$FF,(a3)     ; Set warning flag for 68000 processor.
  38.         bra.b   _done
  39.  
  40. _010    btst    #1,d0
  41.         bne.s   _020            ; 68020
  42.         move.b  #"1",(a1)
  43. ;        move.w  #"ER",(a2)    ; Don't cause error flag if 68010 found.
  44.         bra.b   _done
  45.  
  46. _020    btst    #2,d0
  47.         bne.s   _030            ; 68030
  48.         move.b  #"2",(a1)
  49.         bra.b   _done
  50. _030    btst    #3,d0
  51.         bne.s   _040            ; 68040
  52.         move.b  #"3",(a1)
  53.         bra.b   _done
  54. _040    btst    #7,d0
  55.         bne.s   _060            ; 68060
  56.         move.b  #"4",(a1)
  57.         bra.b   _done
  58. _060    move.b  #"6",(a1)
  59.  
  60. _done   bsr AbrirDOS            ; open DOS.library
  61.         WRITE _header,_stdout   ; write header
  62.  
  63.         bsr     AGA_Check       ; Check for AGA chip set
  64.  
  65.         cmp.l   #"AGA.",d7
  66.         bne     _notaga
  67.  
  68.         WRITE _aga,_stdout      
  69.  
  70.         bra     _continue
  71.  
  72. _notaga WRITE   _not_aga,_stdout
  73.  
  74. _continue
  75.  
  76.         move.l  4.w,a6
  77.         cmp.b   #50,530(A6)     ; Check for PAL/NTSC
  78.         bne     _nopal
  79.  
  80.         WRITE   _pal,_stdout
  81.  
  82.         bra     _cont2
  83.  
  84. _nopal  lea     _status,a2
  85.         move.w  #"ER",(a2)
  86.         WRITE   _ntsc,_stdout
  87.         bra     _failed
  88.  
  89. _cont2
  90.         lea     _status,a2
  91.         cmp.w   #"ER",(a2)
  92.         bne     _systemok
  93. _failed
  94.         WRITE   _abort1,_stdout
  95.  
  96.         bsr CerrarDOS              ; cerramos librería DOS
  97.         moveq #0,d0                ; retorno al Shell sin error
  98.         rts                        ; retorno
  99.  
  100. _systemok
  101.  
  102. ;Now we can check for chip/fast memory...
  103.  
  104.  
  105.         lea     _chipmem,a2
  106.  
  107.         move.l  4.w,a6          ; exec base
  108.         move.l  #$00020002,d1   ; chip mem
  109.         jsr     -216(a6)        ; _LVOAvailMem
  110.         move.l  d0,(a2)+
  111.         move.l  #$00020004,d1   ; fast mem
  112.         jsr     -216(a6)        ; _LVOAvailMem
  113.         move.l  d0,(a2)
  114.  
  115. ; And now let's convert the data into ASCII...
  116.  
  117.         lea     _chipmem,a2
  118.         lea     _cmem,a3        ; string pointer
  119.         lea     _values,a4      ; Table for Hex-Ascii conversion
  120.         move.l  (a2)+,d0        ; amount of chip mem
  121.  
  122.         bsr     converter       ; do conversion.
  123.  
  124.         move.l  (a2),d0         ; amount of fast mem
  125.         lea     _fmem,a3        ; string pointer
  126.  
  127.         bsr     converter       ; convert values
  128.  
  129.         WRITE   _chip,_stdout
  130.  
  131. _fast_ok
  132.         WRITE   _passd,_stdout
  133.  
  134.         bsr     CerrarDOS       ; close dos.library
  135.         
  136. ;--------------------------------------------------
  137. ; Close system and store old IRQ/DMA/Copper values.
  138. ;--------------------------------------------------
  139.  
  140.         lea     gfx_lib,a1      ; open graphics.library
  141.         moveq   #0,d0
  142.         move.l  4.w,a6          ; exec base
  143.         jsr     -552(a6)        ; _LVOOpenLibrary
  144.  
  145.         move.l  d0,_gfxbase     ; store open gfxlibrary pointer
  146.         move.l  d0,a6
  147.         move.l  38(a6),_oldcopper       ; store old copper list address
  148.         move.l  34(a6),_oldview         ; store old WB view.
  149.  
  150.         jsr     -228(a6)        ; _LVOWaitBlitt
  151.         jsr     -456(a6)        ; _LVOOwnBlitter                
  152.  
  153.         moveq   #0,d7
  154.         move.l  d7,a1
  155.  
  156.         jsr     -222(a6)        ; _LVOLoadView(Null)
  157.         jsr     -270(a6)        ; _LVOWaitTOF
  158.         jsr     -270(a6)        ; _LVOWaitTOF
  159.  
  160.         move.l  4.w,a6
  161.         jsr     -132(a6)        ; _LVOForbid
  162.  
  163.  
  164.     lea    _warning,a3
  165.     cmp.w    #$FF,(a3)
  166.     beq.b    _avoid        ; avoid a complete hang up on 68000
  167.     
  168.         lea     GetVBR(pc),a5
  169.         jsr     -$1e(a6)        ; _LVOSupervisor
  170.  
  171. _avoid
  172.         move    $DFF01C,_intenar
  173.         move    $DFF01E,_intreqr
  174.         move    $DFF002,_dmaconr
  175.         move    $DFF010,_adkconr
  176.  
  177.         move    #%0111111111111111,$DFF09A      ; Intena
  178.         move    #%1100000000100000,$DFF09A      ; enable needed IRQs
  179.  
  180.         move.l  _gfxbase,a6
  181.         jsr     -270(a6)        ; WaitTOF
  182.  
  183.         move    #%0111111111111111,$DFF096      ; DMACONW
  184.         move    #%1000001111000000,$DFF096
  185.         
  186.  
  187.         move.l  _vectorbase,a0
  188.         move.l  $6c(a0),_int3save               ; store original vblank int.
  189.                 
  190.         jsr     _maincode       ; call main demo code
  191.  
  192.  
  193.         move.l  _vectorbase,a0
  194.         move.l  _int3save,$6c(a0)       ; restore old level3 int.
  195.  
  196.         move    _intenar,d7
  197.         bset    #$f,d7
  198.         move    d7,$DFF09A              ; restore old interrupts.
  199.  
  200.         move    _intreqr,d7
  201.         bset    #$f,d7
  202.         move    d7,$DFF09C              ; the same...   
  203.         
  204.         move    _dmaconr,d7
  205.         bset    #$f,d7
  206.         move    d7,$DFF096              ; restore old DMAs
  207.  
  208.         move    _adkconr,d7
  209.         bset    #$f,d7
  210.         move    d7,$DFF09E              ; restore Adkcon
  211.  
  212.         move.l  _gfxbase,a6
  213.         move.l  _oldview,a1
  214.         jsr     -222(a6)                ; _LVOLoadview(OldView)
  215.  
  216.         move.l  _oldcopper,$dff080      ; restore old copper list.
  217.  
  218.         jsr     -462(a6)                ; _LVODisownBlitter
  219.  
  220.         move.l  4.w,a6
  221.         move.l  _gfxbase,a1
  222.         jsr     -414(a6)                ; close graphics.library
  223.  
  224.         jsr     -138(a6)                ; _LVOPermit
  225.  
  226.         moveq   #0,d0
  227.         rts
  228.         
  229. ;--------------------------------------------------------------------
  230. ; Hex to Ascii conversion routine.
  231. ; IN: D0.l = Number, A3 = Pointer to string, A4 = Pointer to _values.
  232. ;--------------------------------------------------------------------
  233.  
  234. converter
  235.         move.l  d0,d6   ; store number.
  236.         moveq   #28,d7  ; bits to be shifted.
  237. do_conv
  238.         lsr.l   d7,d0   ; d0.b is now MSB
  239.         and.w   #$000F,d0
  240.         move.b  (A4,d0.w),(a3)+ ; Copy value to string.
  241.  
  242.         move.l  d6,d0
  243.         subq.w   #4,d7
  244.         cmp.w     #-4,d7
  245.         bne     do_conv 
  246.  
  247.         rts
  248.  
  249. ;-------------------------
  250. ; AGA chipset tester.
  251. ; Setpatch MUST be loaded!
  252. ;-------------------------
  253.  
  254. AGA_Check
  255.         lea     gfx_lib,a1
  256.         moveq   #0,d0
  257.         move.l  4.w,a6
  258.         jsr     -552(a6)
  259.  
  260.         btst    #2,$EC(A0)
  261.         bne.s   is_aa
  262.         moveq   #0,d7
  263.         bra.s   not_aga
  264. is_aa   move.l  #'AGA.',d7      
  265.  
  266. not_aga move.l  a0,a1
  267.         jsr     -414(a6)
  268.         rts
  269.  
  270. ;--------------------------------------
  271. ; Store VBR value.
  272. ; Processor MUST be in Supervisor mode.
  273. ;--------------------------------------
  274.  
  275. GetVBR  movec   VBR,D0
  276.         lea     _vectorbase,a0
  277.         move.l  d0,(a0)
  278.         RTE
  279.  
  280. ;-------------------
  281. ; dos.library stuff.
  282. ;-------------------
  283.  
  284. AbrirDOS:
  285.          move.l   _AbsExecBase,_ExecBase   ; store exec base
  286.          lea      dos_name,a1              ; dos.library
  287.          moveq    #0,d0                    ; any version
  288.          CALLSYS  OpenLibrary,_ExecBase   
  289.          move.l   d0,_DOSBase              ; store Dos.library pointer
  290.          beq      ERROR                    
  291.  
  292.          CALLSYS  Output,_DOSBase          ; output descriptor.
  293.          move.l   d0,_stdout               ; store descriptor.
  294.          beq      CerrarDOS                
  295.          CALLSYS  Input,_DOSBase           ; input descriptor.
  296.          move.l   d0,_stdin                
  297.          beq      CerrarDOS                
  298.          rts                               
  299.  
  300. CerrarDOS:
  301.         move.l   _DOSBase,a1               ; 
  302.         CALLSYS  CloseLibrary,_ExecBase    ;close dos.library
  303.         rts                                
  304.  
  305. ERROR:  clr.l    d0        ; exit to shell in case of error.
  306.         rts
  307.  
  308. ;------------------------------------------------------------------------
  309. ; Text and misc data for startup/restore routines.
  310. ;------------------------------------------------------------------------
  311.  
  312.  
  313.     section    stup_data,data
  314.     
  315. _stdout         ds.l    1             
  316. _stdin          ds.l    1             
  317. _ExecBase       ds.l    1             
  318. _DOSBase        ds.l    1             
  319.  
  320. _status dc.w    0
  321. _warning    dc.w    0    ; Will be set to $FF if 68000 to avoid 
  322.                 ; an attempt to read the VBR register.
  323.  
  324. _values dc.b    '0123456789ABCDEF'
  325.  
  326. _chipmem        dc.l    0
  327. _fastmem        dc.l    0
  328.  
  329. _gfxbase        dc.l    0
  330. _oldcopper      dc.l    0
  331. _oldview        dc.l    0
  332. _vectorbase     dc.l    0
  333. _intenar        dc.w    0
  334. _intreqr        dc.w    0
  335. _dmaconr        dc.w    0
  336. _adkconr        dc.w    0
  337. _int3save       dc.l    0
  338.  
  339. dos_name        dc.b    "dos.library",0
  340. gfx_lib     dc.b    "graphics.library",0,0
  341.  
  342. _header dc.b LF,' Hardware Configuration Test 1.06 © 1996 Capsule '
  343.         dc.b LF,' -----------------------------------------------',LF
  344.         dc.b LF,' 680'
  345. _cpu    dc.b 'x0 processor found.'
  346.  
  347. _header_long EQU *-_header
  348.  
  349. _aga    dc.b LF,' AGA chipset found.'
  350.                
  351. _aga_long EQU *-_aga
  352.  
  353. _not_aga dc.b LF,' OCS/ECS chipset found.'
  354.  
  355. _not_aga_long EQU *-_not_aga
  356.  
  357. _pal    dc.b  LF,' PAL display.'
  358.  
  359. _pal_long       equ     *-_pal
  360.  
  361. _ntsc   dc.b  LF,' System is not PAL.'
  362.  
  363. _ntsc_long      EQU     *-_ntsc
  364.  
  365. _chip   dc.b  LF,LF,' Chip Memory: $'
  366.  
  367. _cmem   dc.b  '00000000 bytes available.'
  368.  
  369.         dc.b  LF,' Fast Memory: $'
  370.  
  371. _fmem   dc.b  '00000000 bytes available.'
  372.  
  373. _chip_long      equ     *-_chip
  374.  
  375. _abort1 dc.b  LF,LF,' Hardware test failed. Program aborted...',LF,LF
  376.  
  377. _abort1_long   EQU *-_abort1
  378.  
  379. _abort2 dc.b  LF,LF,' Sorry, this demo requires some FAST memory.'
  380.         dc.b  LF,LF
  381.  
  382. _abort2_long   EQU *-_abort2
  383.         
  384. _passd dc.b LF,LF,' Hardware test passed. Running demo...',LF,LF
  385.  
  386. _passd_long EQU 42
  387.  
  388.  
  389. ;----------------------------------------------------------------------------
  390. ; Real code starts here if everything went ok.
  391. ;----------------------------------------------------------------------------
  392.  
  393.  
  394.     section    democode,code
  395.     
  396.                 
  397. _maincode       nop
  398.                 rts
  399.